import Vue from 'vue';
import Router from 'vue-router';
import {constantRoutes} from './consistant';

Vue.use(Router);

const createRouter = () =>
  new Router({
    mode: 'history',
    scrollBehavior: () => ({y: 0}),
    base: process.env.BASE_URL,
    linkActiveClass: 'active',
    routes: constantRoutes
  });
const router = createRouter();

export default router;

export function resetRouter() {
  const newRouter = createRouter();
  router.matcher = newRouter.matcher; // the relevant part
}
